import java.io.File;
import java.util.ArrayList;

public class Main {


    public static ArrayList<String> getFiles(String path) {
        ArrayList<String> files = new ArrayList<String>();
        File file = new File(path);
        File[] tempList = file.listFiles();

        for (int i = 0; i < tempList.length; i++) {
            if (tempList[i].isFile()) {
//              System.out.println("文     件：" + tempList[i]);
                files.add(tempList[i].toString());
            }
            if (tempList[i].isDirectory()) {
//              System.out.println("文件夹：" + tempList[i]);
            }
        }
        return files;
    }

    public static void main(String[] args) {
        String path = "/Users/liuhuan/Desktop/发票/打车行程单/";
        ArrayList<String> fileNames = getFiles(path);
        double ans = 0;
        int n = 0;
        for (String fileName : fileNames) {
            if (fileName.endsWith(".pdf")) {
                n++;
                String aa = fileName.split("/")[6].split("-")[2].replace("元", "");
                ans += Double.parseDouble(aa);
            }
        }
        System.out.println(ans);
        System.out.println("n = " + n);
    }

}

